package com.msi.visualization;

import java.awt.Color;
import java.util.HashMap;
import java.util.Map;

/**
 * @author karol.galazka
 * Klasa, która generuje mapę koloró
 */
public class ColorMap extends HashMap<Integer, Color> {
	public ColorMap(int numberOfColors) {
		int r = 0, g = 0, b = 0;
		int diff = 765 / numberOfColors;
		for (int i = 0; i < numberOfColors; ++i) {
			if (r + diff <= 255) {
				r += diff;
			} else if (g + diff <= 255) {
				g += diff + r - 255;
				r = 255;
			} else if (r == 0 && diff <= 510) {
				r = 255;
				g += diff - 255;
			} else if (g == 0) {
				r = 255;
				g = 255;
				b = diff - 510;
			} else {
				b += diff + r + g - 255 - 255;
				r = 255;
				g = 255;
			}
			put(i, new Color(r, g, b));
		}
	}
}
